{"ast":null,"code":"import * as React from 'react';\nimport { convertChildrenToData } from \"../utils/legacyUtil\";\n/**\n * Parse `children` to `options` if `options` is not provided.\n * Then flatten the `options`.\n */\n\nexport default function useOptions(options, children, fieldNames, optionFilterProp, optionLabelProp) {\n  return React.useMemo(function () {\n    var mergedOptions = options;\n    var childrenAsData = !options;\n    if (childrenAsData) {\n      mergedOptions = convertChildrenToData(children);\n    }\n    var valueOptions = new Map();\n    var labelOptions = new Map();\n    var setLabelOptions = function setLabelOptions(labelOptionsMap, option, key) {\n      if (key && typeof key === 'string') {\n        labelOptionsMap.set(option[key], option);\n      }\n    };\n    function dig(optionList) {\n      var isChildren = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n\n      // for loop to speed up collection speed\n      for (var i = 0; i < optionList.length; i += 1) {\n        var option = optionList[i];\n        if (!option[fieldNames.options] || isChildren) {\n          valueOptions.set(option[fieldNames.value], option);\n          setLabelOptions(labelOptions, option, fieldNames.label); // https://github.com/ant-design/ant-design/issues/35304\n\n          setLabelOptions(labelOptions, option, optionFilterProp);\n          setLabelOptions(labelOptions, option, optionLabelProp);\n        } else {\n          dig(option[fieldNames.options], true);\n        }\n      }\n    }\n    dig(mergedOptions);\n    return {\n      options: mergedOptions,\n      valueOptions: valueOptions,\n      labelOptions: labelOptions\n    };\n  }, [options, children, fieldNames, optionFilterProp, optionLabelProp]);\n}","map":{"version":3,"names":["React","convertChildrenToData","useOptions","options","children","fieldNames","optionFilterProp","optionLabelProp","useMemo","mergedOptions","childrenAsData","valueOptions","Map","labelOptions","setLabelOptions","labelOptionsMap","option","key","set","dig","optionList","isChildren","arguments","length","undefined","i","value","label"],"sources":["/data/messenger.client/node_modules/rc-select/es/hooks/useOptions.js"],"sourcesContent":["import * as React from 'react';\nimport { convertChildrenToData } from \"../utils/legacyUtil\";\n/**\n * Parse `children` to `options` if `options` is not provided.\n * Then flatten the `options`.\n */\n\nexport default function useOptions(options, children, fieldNames, optionFilterProp, optionLabelProp) {\n  return React.useMemo(function () {\n    var mergedOptions = options;\n    var childrenAsData = !options;\n\n    if (childrenAsData) {\n      mergedOptions = convertChildrenToData(children);\n    }\n\n    var valueOptions = new Map();\n    var labelOptions = new Map();\n\n    var setLabelOptions = function setLabelOptions(labelOptionsMap, option, key) {\n      if (key && typeof key === 'string') {\n        labelOptionsMap.set(option[key], option);\n      }\n    };\n\n    function dig(optionList) {\n      var isChildren = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n\n      // for loop to speed up collection speed\n      for (var i = 0; i < optionList.length; i += 1) {\n        var option = optionList[i];\n\n        if (!option[fieldNames.options] || isChildren) {\n          valueOptions.set(option[fieldNames.value], option);\n          setLabelOptions(labelOptions, option, fieldNames.label); // https://github.com/ant-design/ant-design/issues/35304\n\n          setLabelOptions(labelOptions, option, optionFilterProp);\n          setLabelOptions(labelOptions, option, optionLabelProp);\n        } else {\n          dig(option[fieldNames.options], true);\n        }\n      }\n    }\n\n    dig(mergedOptions);\n    return {\n      options: mergedOptions,\n      valueOptions: valueOptions,\n      labelOptions: labelOptions\n    };\n  }, [options, children, fieldNames, optionFilterProp, optionLabelProp]);\n}"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,qBAAqB,QAAQ,qBAAqB;AAC3D;AACA;AACA;AACA;;AAEA,eAAe,SAASC,UAAU,CAACC,OAAO,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,gBAAgB,EAAEC,eAAe,EAAE;EACnG,OAAOP,KAAK,CAACQ,OAAO,CAAC,YAAY;IAC/B,IAAIC,aAAa,GAAGN,OAAO;IAC3B,IAAIO,cAAc,GAAG,CAACP,OAAO;IAE7B,IAAIO,cAAc,EAAE;MAClBD,aAAa,GAAGR,qBAAqB,CAACG,QAAQ,CAAC;IACjD;IAEA,IAAIO,YAAY,GAAG,IAAIC,GAAG,EAAE;IAC5B,IAAIC,YAAY,GAAG,IAAID,GAAG,EAAE;IAE5B,IAAIE,eAAe,GAAG,SAASA,e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